package com.gxa.service.impl;

import com.gxa.dto.*;
import com.gxa.entity.Goods;
import com.gxa.entity.GoodsDetail;
import com.gxa.mapper.GoodsDetailMapper;
import com.gxa.mapper.GoodsMapper;
import com.gxa.mapper.StockMapper;
import com.gxa.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service

public class GoodsServiceImpl  implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private GoodsDetailMapper goodsDetailMapper;
    @Autowired
    private StockMapper stockMapper;


    @Override
    public List<GoodsQueryDto> queryGoodsList() {
        List<GoodsQueryDto> goodsList = this.goodsMapper.queryGoodsList();
        return goodsList;
    }

    @Override
    public List<GoodsQueryDto> queryAll(GoodsDto goodsDto) {
        List<GoodsQueryDto> goodsList = this.goodsMapper.queryAll(goodsDto);
        return goodsList;
    }

    @Override
    public List<GoodsDetail> selectType() {
        List<GoodsDetail> goodsDetailList = this.goodsMapper.selectType();
        return goodsDetailList;
    }

    @Override
    public void updateShelves(GoodsShelvesDto goodsShelvesDto){
       this.goodsMapper.updateShelves(goodsShelvesDto);
    }

    @Override
    @Transactional
    public void addGoods(GoodsAddDto goodsAddDto) { //添加
        this.goodsMapper.addGoods(goodsAddDto);
        this.goodsDetailMapper.addGoodsDetail(goodsAddDto);
        this.stockMapper.addStock(goodsAddDto);

    }

    @Override
    public void updateGoodsById(GoodsDetail goodsDetail) {
        this.goodsMapper.updateGoodsById(goodsDetail);
    }

    @Override
    public List<GoodsTypeQueryDto> queryGoodsAttribute(GoodsTypeConditionDto goodsTypeConditionDto) {
        List<GoodsTypeQueryDto> goodsAttribute = this.goodsMapper.queryGoodsAttribute(goodsTypeConditionDto);
        return goodsAttribute;
    }

    @Override
    public void updateGoodsAttribute(GoodsTypeQueryDto goodsTypeQueryDto) {
        this.goodsMapper.updateGoodsAttribute(goodsTypeQueryDto);
    }


}
